<?php 
		
	include "lib/config.inc.php";
		
	$username = post('username');
	$password = post('password');
	
	
	if ($username != null && $password != null) {
	
		// procurar no BD alguem que tenha o mesmo login e senha que foram enviados no BD....
		$password = sha1(md5($password));
		$res = mysql_query ("SELECT * FROM usuarios WHERE username = '$username' AND password = '$password'");
		$usuario = mysql_fetch_array($res);
		
		if (!$usuario){
		?>	 <link href="../lib/css/bootstrap.css" rel="stylesheet" media="screen">
			<div class="container" >
				<form method='post' action='../admin/validaLogin.php' class="col-md-offset-3 col-md-6 col-md-offset-3" style="margin-top: 15%;">
					<div class="panel panel-primary"><a class="navbar-brand"><img width="30px" src="../admin/imagens/Logo.png"></a>
					<div class="panel-heading"><h4>Mente Ativa</h4></div>
						<div class="panel-body "><div class="col-md-offset-2 col-md-8 col-md-offset-2"><br>
							<fieldset >
								<div class="form-group">
									<div class="input-group">
						  				<span class="input-group-addon">Usu&aacuterio</span>
								      	<input type="text" name="username" class="form-control" maxlength="144">
								    </div>
								</div>
							  	<div class="form-group">
							    	<div class="input-group">
						  				<span class="input-group-addon">Senha  :</span>
							      		<input type="password" name="password" class="form-control" maxlength="60">
							    	</div>
							  	</div>
							  	<div class="form-group">
						    		<div class="controls">
									<button type="submit" class="btn">Entrar</button>
									</div>
								</div>
							</fieldset>
						</div>
					</div>
					</div>
					</form>
					
			</div>
			<?php
			echo '<div class="panel"> <div class="panel-body"><div class="alert col-md-offset-3 col-md-6 col-md-offset-3 alert-danger">
				<button type="button" class="close" data-dismiss="alert"></button>
				<center> <strong>ERRO!</strong> Login ou senha inv&aacutelidos!</center>
				</div></div></div>';
		}
		else {
			session_start();
			$_SESSION['usuario'] = $usuario;
			//echo "Login Realizado!";			
			header('Location: index.php?pg=home');
			
			die ();
		}
		
	}else{
		echo '<div class="panel"> <div class="panel-body"><div class="alert col-md-offset-3 col-md-6 col-md-offset-3 alert-warning">
				<button type="button" class="close" data-dismiss="alert"></button>
				<center> <strong>ATEN&Ccedil&AtildeO!</strong> Preencha os campos de login e senha para acessar o sistema.</center>
				</div></div></div>';
	}
?>